package com.ilikesoup.instant.monitor.sample;

import com.ilikesoup.instant.monitor.core.MonitorBeanWrapper;

import java.util.function.BiConsumer;

public class MonitorBeanFactory implements MonitorBeanWrapper {

    private final BeanMonitorBuilder builder;
    private final BiConsumer copier;

    public MonitorBeanFactory(BeanMonitorBuilder builder) {
        this.builder = builder;
        this.copier = null;
    }

    public MonitorBeanFactory(BeanMonitorBuilder builder, BiConsumer copier) {
        this.builder = builder;
        this.copier = copier;
    }

    @Override
    public Object wrap(Object obj) {
        if(copier == null) {
            return builder.monitor(obj);
        }
        return builder.monitor(obj, copier);
    }

}
